package com.longge;

public class DeleteDuplicatesListNode {

    public ListNode deleteDuplicates(ListNode head) {
        if (head == null) return null;
        ListNode dummy = new ListNode(-1);
        dummy.next = head;
        ListNode slow = head, fast = head;

        while (fast.next != null) {
            if (fast.val != fast.next.val) {
                slow.next = fast.next;
                slow = slow.next;
            }
            fast = fast.next;
        }
        slow.next = null;
        return dummy.next;
    }
}
